﻿using IFRS.DataAccess.DAL;
using IFRS.Models;
using IFRS.Web;
using IFRS_Global;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


public partial class IFRS_WIN30_3V : PageBase
{
    #region "---------- Event -----------"

    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
        if (!IsPostBack)
        {
            ViewMenu();
            BindDDL();
            if (Request.QueryString["id"] != null)
            {
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
            } SetControl();
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");
    }

    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN30_1S.aspx");
    }
    #endregion

    #region "---------- Method -----------"

    private void SetControl()
    {
        SetControlReadOnly(form_control);
    }
    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN30_3V;
    }
    private void BindData(int ID)
    {
        List<InvestmentFairValue> investmentFairValue = new List<InvestmentFairValue>();
        DataTable dt = new SPR_INVESTMENTFAIRVALUE().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {
            ConvertHelper.ConvertDataTableToObject(dt, investmentFairValue);
            txtTransectionDate.Text = DateTime.Now.DateToString();
            ddlIndustryType.SelectedValue = investmentFairValue[0].IndustryTypeID.ToString();
            txtFairValue.Text = investmentFairValue[0].FairValue.DecimalToString();
        }
    }
    private void BindDDL()
    {
        ddlIndustryType.SetData(DDL_TYPE.IndustryType, "", false, true);
    }
    #endregion
}